/**
 * 
 */
package structs;

import interfaces.ICard;
import interfaces.IPlayer;

import java.util.ArrayList;

/**
 * @author Abner
 *
 */
public class TeamStrategy {
	
	private Game game;
	
	//Current Hand
	private ICard hand1;
	private ICard hand2;
	private ICard hand3;

	//Deck
	private ArrayList<ICard> highLifeCards;
	private ArrayList<ICard> midLifeCards;
	private ArrayList<ICard> lowLifeCards;
	private ArrayList<ICard> otherHighCards;
	private ArrayList<ICard> otherMidCards;
	private ArrayList<ICard> otherLowCards;
	private ArrayList<ICard> suit1HighCards;
	private ArrayList<ICard> suit1MidCards;
	private ArrayList<ICard> suit1LowCards;
	private ArrayList<ICard> suit1ElseCards;
	private ArrayList<ICard> suit2HighCards;
	private ArrayList<ICard> suit2MidCards;
	private ArrayList<ICard> suit2LowCards;
	private ArrayList<ICard> suit2ElseCards;
	private ArrayList<ICard> suit3HighCards;
	private ArrayList<ICard> suit3MidCards;
	private ArrayList<ICard> suit3LowCards;
	private ArrayList<ICard> suit3ElseCards;
	
	private ArrayList<ICard> lowBCards;
	private ArrayList<ICard> midBCards;
	private ArrayList<ICard> highBCards;
	
	private ArrayList<ICard> lowCCards;
	private ArrayList<ICard> midCCards;
	private ArrayList<ICard> highCCards;
	
	private ArrayList<ICard> lowECards;
	private ArrayList<ICard> midECards;
	private ArrayList<ICard> highECards;
	
	private ArrayList<ICard> lowOCards;
	private ArrayList<ICard> midOCards;
	private ArrayList<ICard> highOCards;
	
	public TeamStrategy(Game game){
		this.game = game;
	}
	
	private void setup_Deck(){
		this.highLifeCards = new ArrayList<ICard>();
		this.midLifeCards = new ArrayList<ICard>();
		this.lowLifeCards = new ArrayList<ICard>();
		
		this.highBCards = new ArrayList<ICard>();
		this.midBCards = new ArrayList<ICard>();
		this.lowBCards = new ArrayList<ICard>();
		
		this.highCCards = new ArrayList<ICard>();
		this.midCCards = new ArrayList<ICard>();
		this.lowCCards = new ArrayList<ICard>();
		
		this.highECards = new ArrayList<ICard>();
		this.midECards = new ArrayList<ICard>();
		this.lowECards = new ArrayList<ICard>();
		
		this.highOCards = new ArrayList<ICard>();
		this.midOCards = new ArrayList<ICard>();
		this.lowOCards = new ArrayList<ICard>();
		
		this.otherHighCards = new ArrayList<ICard>();
		this.otherMidCards = new ArrayList<ICard>();
		this.otherLowCards = new ArrayList<ICard>();

		this.suit1HighCards = new ArrayList<ICard>();
		this.suit1MidCards = new ArrayList<ICard>();
		this.suit1LowCards = new ArrayList<ICard>();
		this.suit1ElseCards = new ArrayList<ICard>();
		this.suit2HighCards = new ArrayList<ICard>();
		this.suit2MidCards = new ArrayList<ICard>();
		this.suit2LowCards = new ArrayList<ICard>();
		this.suit2ElseCards = new ArrayList<ICard>();
		this.suit3HighCards = new ArrayList<ICard>();
		this.suit3MidCards = new ArrayList<ICard>();
		this.suit3LowCards = new ArrayList<ICard>();
		this.suit3ElseCards = new ArrayList<ICard>();

		IPlayer ai = this.game.getAIPlayer();
		Deck deck = this.game.getDeck();

		this.hand1 = ai.getCurrentHand().get(0); //Hand 1
		this.hand1 = ai.getCurrentHand().get(1); //Hand 2
		this.hand1 = ai.getCurrentHand().get(2); //Hand 3
		
		for(ICard card : deck.getCards())
		{
			if(card.getSuit().equalsIgnoreCase(deck.getLife().getSuit()))
			{
				if(card.getPoints() > 4)
				{
					this.highLifeCards.add(card);
				}
				
				else if(card.getPoints() >0 && card.getPoints() <=4)
				{
					this.midLifeCards.add(card);
				}
				
				else
				{
					this.lowLifeCards.add(card);
				}	
			}
			
			else
			{
				if(card.getPoints() > 4)
				{
					this.otherHighCards.add(card);
				}
				
				else if(card.getPoints() >0 && card.getPoints() <=4)
				{
					this.otherMidCards.add(card);
				}
				
				else
				{
					this.otherLowCards.add(card);
				}	
			}
		}
		

		if(this.hand1 != null){
			for(ICard card : deck.getCards()){
				if(card.getSuit().equalsIgnoreCase(this.hand1.getSuit())){
					if(card.getPoints() > this.hand1.getPoints()){
						this.suit1HighCards.add(card);
					}
					else{
						this.suit1LowCards.add(card);
					}	
				}
				else{
					this.suit1ElseCards.add(card);
				}
			}
		}



		this.hand2 = ai.getCurrentHand().get(1);

		if(this.hand2 != null){
			for(ICard card : deck.getCards()){
				if(card.getSuit().equalsIgnoreCase(this.hand2.getSuit())){
					if(card.getPoints() > this.hand2.getPoints()){
						this.suit2HighCards.add(card);
					}
					else{
						this.suit2LowCards.add(card);
					}	
				}
				else{
					this.suit2ElseCards.add(card);
				}
			}
		}

		this.hand3 = ai.getCurrentHand().get(2);
		if(this.hand3 != null){
			for(ICard card : deck.getCards()){
				if(card.getSuit().equalsIgnoreCase(this.hand3.getSuit())){
					if(card.getPoints() > this.hand3.getPoints()){
						this.suit3HighCards.add(card);
					}
					else{
						this.suit3LowCards.add(card);
					}	
				}
				else{
					this.suit3ElseCards.add(card);
				}
			}
		}
	}

}